home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / freeware / pixeltoolbox / Setup.exe / Main / PixelToolbox.exe / PixelToolbox.dxr / Scripts_72_canvas script - rgb.ls < prev    next >
Encoding:
Text File  |  2002-06-08  |  14.3 KB  |  383 lines

  1. property pSprite, pUndoTrigger
  2. global gProject, gSize, gCast, gVariable, gFirstColor, gSecondColor, gPencilSize, gPencilShape, gEraserSize, gEraserShape, gBrushSize, gBrushShape, gAirbrushSize, gAirbrushShape, gGradientDirection, gClonerShape, gClonerSize, gClonerFlag, gClonerHDist, gClonerVDist, myCurrentImage, pPixelActorListX, pPixelActorListY, pSpreadListX, pSpreadListY, currentCursor, gCurrentColor, gShapeType, gRectStyle, gOvalStyle, gRoundRectStyle, gWvBgColor, gWvBgShadow, gWvVcolor, gWvVShadow, gWvHcolor, gWvHShadow, gMarqueeRect
  3.  
  4. on beginSprite me
  5.   pSprite = sprite(me.spriteNum)
  6.   pUndoTrigger = 0
  7. end
  8.  
  9. on mouseWithin me
  10.   if sprite(64).pState = 1 then
  11.     if gPencilSize = 1 then
  12.       nothing()
  13.     else
  14.       sprite(8).rect = rect(the mouseH - (gPencilSize * gVariable / 2), the mouseV - (gPencilSize * gVariable / 2), the mouseH + (gPencilSize * gVariable / 2), the mouseV + (gPencilSize * gVariable / 2))
  15.     end if
  16.   else
  17.     if sprite(73).pState = 1 then
  18.       sprite(8).rect = rect(the mouseH - (gBrushSize * gVariable / 2), the mouseV - (gBrushSize * gVariable / 2), the mouseH + (gBrushSize * gVariable / 2), the mouseV + (gBrushSize * gVariable / 2))
  19.     else
  20.       if sprite(84).pState = 1 then
  21.         if gEraserSize = 1 then
  22.           nothing()
  23.         else
  24.           sprite(8).rect = rect(the mouseH - (gEraserSize * gVariable / 2), the mouseV - (gEraserSize * gVariable / 2), the mouseH + (gEraserSize * gVariable / 2), the mouseV + (gEraserSize * gVariable / 2))
  25.         end if
  26.       else
  27.         if sprite(96).pState = 1 then
  28.           sprite(8).rect = rect(the mouseH - (gAirbrushSize * gVariable / 2), the mouseV - (gAirbrushSize * gVariable / 2), the mouseH + (gAirbrushSize * gVariable / 2), the mouseV + (gAirbrushSize * gVariable / 2))
  29.         else
  30.           if sprite(104).pState = 1 then
  31.             if gClonerSize = 1 then
  32.               if gClonerFlag = 0 then
  33.                 nothing()
  34.               else
  35.                 sprite(9).loc = point(((the mouseH - sprite(1).left) * 2 / gVariable / 2 * gVariable) + sprite(1).left + (gVariable / 2) + (gClonerHDist * gVariable), ((the mouseV - sprite(1).top) * 2 / gVariable / 2 * gVariable) + sprite(1).top + (gVariable / 2) + (gClonerVDist * gVariable))
  36.               end if
  37.             else
  38.               if gClonerFlag = 0 then
  39.                 sprite(8).rect = rect(the mouseH - (gClonerSize * gVariable / 2), the mouseV - (gClonerSize * gVariable / 2), the mouseH + (gClonerSize * gVariable / 2), the mouseV + (gClonerSize * gVariable / 2))
  40.               else
  41.                 sprite(8).rect = rect(the mouseH - (gClonerSize * gVariable / 2), the mouseV - (gClonerSize * gVariable / 2), the mouseH + (gClonerSize * gVariable / 2), the mouseV + (gClonerSize * gVariable / 2))
  42.                 sprite(9).loc = point(((the mouseH - sprite(1).left) * 2 / gVariable / 2 * gVariable) + sprite(1).left + (gVariable / 2) + (gClonerHDist * gVariable), ((the mouseV - sprite(1).top) * 2 / gVariable / 2 * gVariable) + sprite(1).top + (gVariable / 2) + (gClonerVDist * gVariable))
  43.               end if
  44.             end if
  45.           else
  46.             if sprite(146).pState = 1 then
  47.               if (gMarqueeRect <> rect(0, 0, 0, 0)) and inside(point(the mouseH, the mouseV), gMarqueeRect) then
  48.                 pSprite.cursor = [412, 413]
  49.               else
  50.                 pSprite.cursor = 271
  51.               end if
  52.             end if
  53.           end if
  54.         end if
  55.       end if
  56.     end if
  57.   end if
  58.   put (the mouseH - sprite(1).left) * 2 / gVariable / 2 into field "location status X"
  59.   put (the mouseV - sprite(1).top) * 2 / gVariable / 2 into field "location status Y"
  60. end
  61.  
  62. on mouseEnter me
  63.   if sprite(64).pState = 1 then
  64.     pSprite.cursor = 256
  65.     member(391).shapeType = gPencilShape
  66.   else
  67.     if sprite(73).pState = 1 then
  68.       pSprite.cursor = [350, 351]
  69.       member(391).shapeType = gBrushShape
  70.     else
  71.       if sprite(84).pState = 1 then
  72.         pSprite.cursor = [352, 353]
  73.         member(391).shapeType = gEraserShape
  74.       else
  75.         if sprite(96).pState = 1 then
  76.           pSprite.cursor = [354, 355]
  77.           member(391).shapeType = gAirbrushShape
  78.         else
  79.           if sprite(104).pState = 1 then
  80.             pSprite.cursor = [348, 349]
  81.             member(391).shapeType = gClonerShape
  82.           else
  83.             if sprite(116).pState = 1 then
  84.               pSprite.cursor = 271
  85.               gShapeType = #rect
  86.             else
  87.               if sprite(121).pState = 1 then
  88.                 pSprite.cursor = 271
  89.                 gShapeType = #oval
  90.               else
  91.                 if sprite(126).pState = 1 then
  92.                   pSprite.cursor = 271
  93.                   gShapeType = #roundRect
  94.                 else
  95.                   if sprite(131).pState = 1 then
  96.                     pSprite.cursor = 271
  97.                   else
  98.                     if sprite(138).pState = 1 then
  99.                       pSprite.cursor = 271
  100.                     else
  101.                       if sprite(142).pState = 1 then
  102.                         pSprite.cursor = 259
  103.                       else
  104.                         if sprite(143).pState = 1 then
  105.                           pSprite.cursor = [344, 345]
  106.                         else
  107.                           if sprite(144).pState = 1 then
  108.                             pSprite.cursor = [346, 347]
  109.                           else
  110.                             if sprite(147).pState = 1 then
  111.                               pSprite.cursor = 1
  112.                             else
  113.                               if sprite(240).pState = 1 then
  114.                                 pSprite.cursor = [432, 433]
  115.                               end if
  116.                             end if
  117.                           end if
  118.                         end if
  119.                       end if
  120.                     end if
  121.                   end if
  122.                 end if
  123.               end if
  124.             end if
  125.           end if
  126.         end if
  127.       end if
  128.     end if
  129.   end if
  130.   currentCursor = pSprite.cursor
  131. end
  132.  
  133. on mouseLeave me
  134.   pSprite.cursor = 0
  135.   put EMPTY into field "location status X"
  136.   put EMPTY into field "location status Y"
  137.   if (sprite(64).pState = 1) or (sprite(73).pState = 1) or (sprite(84).pState = 1) or (sprite(96).pState = 1) or (sprite(104).pState = 1) then
  138.     sprite(8).rect = rect(-60, -60, 0, 0)
  139.   end if
  140. end
  141.  
  142. on mouseDown
  143.   if pUndoTrigger = 0 then
  144.     if sprite(146).pState <> 1 then
  145.       pUndoTrigger = 1
  146.     end if
  147.   end if
  148.   if sprite(64).pState = 1 then
  149.     if gPencilSize = 1 then
  150.       tool1PxPencil()
  151.     else
  152.       toolPencil()
  153.     end if
  154.   else
  155.     if sprite(73).pState = 1 then
  156.       toolBrush()
  157.     else
  158.       if sprite(84).pState = 1 then
  159.         if gEraserSize = 1 then
  160.           tool1PxEraser()
  161.         else
  162.           toolEraser()
  163.         end if
  164.       else
  165.         if sprite(96).pState = 1 then
  166.           toolRGBAirbrush()
  167.         else
  168.           if sprite(104).pState = 1 then
  169.             if gClonerSize = 1 then
  170.               tool1PxCloner()
  171.             else
  172.               toolCloner()
  173.             end if
  174.           else
  175.             if sprite(116).pState = 1 then
  176.               if gRectStyle = "outline" then
  177.                 toolOutlineShape()
  178.               else
  179.                 if gRectStyle = "filled" then
  180.                   toolFilledShape()
  181.                 else
  182.                   if gRectStyle = "solid" then
  183.                     toolSolidShape()
  184.                   end if
  185.                 end if
  186.               end if
  187.             else
  188.               if sprite(121).pState = 1 then
  189.                 if gOvalStyle = "outline" then
  190.                   toolOutlineShape()
  191.                 else
  192.                   if gOvalStyle = "filled" then
  193.                     toolFilledShape()
  194.                   else
  195.                     if gOvalStyle = "solid" then
  196.                       toolSolidShape()
  197.                     end if
  198.                   end if
  199.                 end if
  200.               else
  201.                 if sprite(126).pState = 1 then
  202.                   if gRoundRectStyle = "outline" then
  203.                     toolOutlineShape()
  204.                   else
  205.                     if gRoundRectStyle = "filled" then
  206.                       toolFilledShape()
  207.                     else
  208.                       if gRoundRectStyle = "solid" then
  209.                         toolSolidShape()
  210.                       end if
  211.                     end if
  212.                   end if
  213.                 else
  214.                   if sprite(131).pState = 1 then
  215.                     toolStraightLine()
  216.                   else
  217.                     if sprite(138).pState = 1 then
  218.                       if gGradientDirection = "H" then
  219.                         toolGradientH32()
  220.                       else
  221.                         if gGradientDirection = "V" then
  222.                           toolGradientV32()
  223.                         else
  224.                           if gGradientDirection = "rect" then
  225.                             toolGradientRect32()
  226.                           else
  227.                             if gGradientDirection = "oval" then
  228.                               toolGradientOval32()
  229.                             end if
  230.                           end if
  231.                         end if
  232.                       end if
  233.                     else
  234.                       if sprite(142).pState = 1 then
  235.                         toolFill()
  236.                       else
  237.                         if sprite(143).pState = 1 then
  238.                           toolCheckerFill()
  239.                         else
  240.                           if sprite(144).pState = 1 then
  241.                             toolChangeColor()
  242.                           else
  243.                             if sprite(146).pState = 1 then
  244.                               if (gMarqueeRect <> rect(0, 0, 0, 0)) and inside(point(the mouseH, the mouseV), gMarqueeRect) then
  245.                                 moveSelect()
  246.                               else
  247.                                 toolSelect()
  248.                               end if
  249.                             else
  250.                               if sprite(147).pState = 1 then
  251.                                 toolText()
  252.                               else
  253.                                 if sprite(240).pState = 1 then
  254.                                   toolWarp()
  255.                                 end if
  256.                               end if
  257.                             end if
  258.                           end if
  259.                         end if
  260.                       end if
  261.                     end if
  262.                   end if
  263.                 end if
  264.               end if
  265.             end if
  266.           end if
  267.         end if
  268.       end if
  269.     end if
  270.   end if
  271. end
  272.  
  273. on rightMouseDown
  274.   if sprite(146).pState = 1 then
  275.     nothing()
  276.   else
  277.     if sprite(104).pState = 1 then
  278.       pSprite.cursor = [359, 360]
  279.       gClonerFlag = 0
  280.       sprite(9).blend = 100
  281.       sprite(9).loc = point(((the mouseH - sprite(1).left) * 2 / gVariable / 2 * gVariable) + sprite(1).left + (gVariable / 2), ((the mouseV - sprite(1).top) * 2 / gVariable / 2 * gVariable) + sprite(1).top + (gVariable / 2))
  282.     else
  283.       pSprite.cursor = [361, 362]
  284.       gCurrentColor = member(gSize & "x" & gSize, gCast).image.getPixel((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2)
  285.       put gCurrentColor.red into field "red status"
  286.       put gCurrentColor.green into field "green status"
  287.       put gCurrentColor.blue into field "blue status"
  288.       put gCurrentColor.hexString() into field "hex status"
  289.       sendSprite(181, #updatecolors)
  290.     end if
  291.   end if
  292. end
  293.  
  294. on rightMouseUp
  295.   if sprite(146).pState = 1 then
  296.     nothing()
  297.   else
  298.     pSprite.cursor = currentCursor
  299.     put EMPTY into field "red status"
  300.     put EMPTY into field "green status"
  301.     put EMPTY into field "blue status"
  302.     put EMPTY into field "hex status"
  303.     put EMPTY into field "paletteIndex status"
  304.   end if
  305. end
  306.  
  307. on mouseUpOutSide
  308.   if the rightMouseUp then
  309.     if sprite(146).pState = 1 then
  310.       nothing()
  311.     else
  312.       pSprite.cursor = currentCursor
  313.       put EMPTY into field "red status"
  314.       put EMPTY into field "green status"
  315.       put EMPTY into field "blue status"
  316.       put EMPTY into field "hex status"
  317.       put EMPTY into field "paletteIndex status"
  318.     end if
  319.   end if
  320. end
  321.  
  322. on mFlood me, aX, aY, aSourceColor
  323.   targetColor = myCurrentImage.getPixel(aX, aY)
  324.   myCurrentImage.setPixel(aX, aY, aSourceColor)
  325.   append(pPixelActorListX, aX)
  326.   append(pPixelActorListY, aY)
  327.   repeat while count(pPixelActorListX)
  328.     xCur = getAt(pPixelActorListX, 1)
  329.     yCur = getAt(pPixelActorListY, 1)
  330.     deleteAt(pPixelActorListX, 1)
  331.     deleteAt(pPixelActorListY, 1)
  332.     repeat with n = 1 to 4
  333.       xTest = xCur + getAt(pSpreadListX, n)
  334.       yTest = yCur + getAt(pSpreadListY, n)
  335.       if myCurrentImage.getPixel(xTest, yTest) = targetColor then
  336.         myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  337.         append(pPixelActorListX, xTest)
  338.         append(pPixelActorListY, yTest)
  339.       end if
  340.     end repeat
  341.   end repeat
  342. end
  343.  
  344. on mFlood2 me, aX, aY, aSourceColor
  345.   targetColor = myCurrentImage.getPixel(aX, aY)
  346.   myCurrentImage.setPixel(aX, aY, aSourceColor)
  347.   append(pPixelActorListX, aX)
  348.   append(pPixelActorListY, aY)
  349.   repeat while count(pPixelActorListX)
  350.     xCur = getAt(pPixelActorListX, 1)
  351.     yCur = getAt(pPixelActorListY, 1)
  352.     deleteAt(pPixelActorListX, 1)
  353.     deleteAt(pPixelActorListY, 1)
  354.     repeat with n = 1 to 4
  355.       xTest = xCur + getAt(pSpreadListX, n)
  356.       yTest = yCur + getAt(pSpreadListY, n)
  357.       if myCurrentImage.getPixel(xTest, yTest) = targetColor then
  358.         if (((aX mod 2) = 1) and ((aY mod 2) = 0)) or (((aX mod 2) = 0) and ((aY mod 2) = 1)) then
  359.           if (((xTest mod 2) = 1) and ((yTest mod 2) = 0)) or (((xTest mod 2) = 0) and ((yTest mod 2) = 1)) then
  360.             myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  361.             append(pPixelActorListX, xTest)
  362.             append(pPixelActorListY, yTest)
  363.           else
  364.             myCurrentImage.setPixel(xTest, yTest, targetColor)
  365.             append(pPixelActorListX, xTest)
  366.             append(pPixelActorListY, yTest)
  367.           end if
  368.           next repeat
  369.         end if
  370.         if (((xTest mod 2) = 1) and ((yTest mod 2) = 0)) or (((xTest mod 2) = 0) and ((yTest mod 2) = 1)) then
  371.           myCurrentImage.setPixel(xTest, yTest, targetColor)
  372.           append(pPixelActorListX, xTest)
  373.           append(pPixelActorListY, yTest)
  374.           next repeat
  375.         end if
  376.         myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  377.         append(pPixelActorListX, xTest)
  378.         append(pPixelActorListY, yTest)
  379.       end if
  380.     end repeat
  381.   end repeat
  382. end
  383.